package com.learn.controller;

import com.learn.service.AiChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/ai")
public class AiChatController {

    @Autowired
    private AiChatService aiChatService;

    @GetMapping("/simple")
    public String simpleChat(@RequestParam String question) {
        return aiChatService.aiSimpleChat(question);
    }

    @GetMapping(value = "/markdown", produces = "text/markdown;charset=UTF-8")
    public String markdownChat(@RequestParam String question) {
        return aiChatService.aiSimpleChat(question);
    }
    
    @GetMapping(value = "/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> streamChat(@RequestParam String question) {
        return aiChatService.streamChat(question);
    }

}